#!/usr/bin/env python

import wx
import component
import resource as r

import __main as main

class Main(component.Frame):
    '''Main object
    
    @author Julot <andy.julot@gmail.com>
    @since Saturday, January 14, 2012. 09:01 AM'''
    
    def __init__(self):
        super(Main, self).__init__(None, name='Main')
        import app
        meta = app.Meta()
        self.Title = '%s Version %s' % (meta.name, meta.long_version)
        self.Icon = r.icon.Main.Icon
        self._realize()
    
    def _realize(self):
        self.MenuBar = main.MenuBar()
        self.ToolBar = main.ToolBar(self)
        self.ToolBar.Realize()
        self.StatusBar = wx.StatusBar(self)
        
        self.splitter = wx.SplitterWindow(self, style=wx.SP_LIVE_UPDATE)
            
        notebook = wx.Notebook(self.splitter)
        self.notebook = notebook
        
        self.messages = main.Messages(notebook)
        self.contacts = main.Contacts(notebook)
        self.groups = main.Groups(notebook)
        self.progress = main.Progress(notebook)
        
        notebook.AddPage(self.messages, r.string.view.main.messages)
        notebook.AddPage(self.contacts, r.string.view.main.contacts)
        notebook.AddPage(self.groups, r.string.view.main.groups)
        notebook.AddPage(self.progress, r.string.view.main.progress)
        
        imageList = wx.ImageList(16, 16)
        notebook.AssignImageList(imageList)
        index = imageList.Add(r.toolbar.Mail.Bitmap)
        notebook.SetPageImage(0, index)
        index = imageList.Add(r.toolbar.UserGreenFemale.Bitmap)
        notebook.SetPageImage(1, index)
        index = imageList.Add(r.toolbar.Users.Bitmap)
        notebook.SetPageImage(2, index)
        index = imageList.Add(r.toolbar.UiProgressBar.Bitmap)
        notebook.SetPageImage(3, index)
        
        self.message = main.Message(self.splitter)
        
        self.splitter.SplitHorizontally(self.notebook, self.message)
        
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.splitter, 1, wx.GROW)
        self.SetSizerAndFit(sizer)
    
    def getStatus(self):
        return self.StatusBar.StatusText
    
    def setStatus(self, text):
        self.StatusBar.StatusText = text
    
    status = property(getStatus, setStatus)